#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;

typedef long long LL;

vector<int> add(vector<int>& A, vector<int>& B) {
    if (A.size() < B.size()) return add(B, A);

    vector<int> C;
    int t = 0;
    for (int i = 0; i < A.size(); i++) {
        t += A[i];
        if (i < B.size()) t += B[i];
        C.push_back(t % 10);
        t /= 10;
    }

    if (t) C.push_back(t);
    return C;
}


pair<int, int> make_pair_int(int a, int b) {
    return make_pair(a, b);
}


void solve(int case_num) {
    int a, b;
    cin >> a >> b;

    vector<int> A, B;
    while (a > 0) {
        A.push_back(a % 10);
        a /= 10;
    }
    while (b > 0) {
        B.push_back(b % 10);
        b /= 10;
    }

    vector<int> result = add(A, B);

    cout << "Case " << case_num << ":" << endl;
    for (int i = result.size() - 1; i >= 0; i--) {
        cout << result[i];
    }
    cout << endl << endl;
}


struct PairHash {
    template <class T1, class T2>
    std::size_t operator () (const std::pair<T1, T2>& p) const {
        auto hash1 = std::hash<T1>{}(p.first);
        auto hash2 = std::hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int t;
    cin >> t;

    unordered_map<pair<int, int>, vector<int>, PairHash> results;

    while (t--) {
        int a, b;
        cin >> a >> b;

        vector<int> A, B;
        int originalA = a, originalB = b;
        while (a > 0) {
            A.push_back(a % 10);
            a /= 10;
        }
        while (b > 0) {
            B.push_back(b % 10);
            b /= 10;
        }

        vector<int> result = add(A, B);


        results[make_pair(originalA, originalB)] = result;

        for (int i = result.size() - 1; i >= 0; i--) {
            cout << result[i];
        }
        cout << endl;
    }

    cout << "Results:" << endl;
    for (auto it = results.begin(); it != results.end(); ++it) {
        pair<int, int> inputs = it->first;
        vector<int> result = it->second;

        cout << "Input: (" << inputs.first << ", " << inputs.second << ") ";
        cout << "Result: ";
        for (int i = result.size() - 1; i >= 0; i--) {
            cout << result[i];
        }
        cout << endl;
    }

    return 0;
}